<HTML><HEAD><TITLE>CS :~ ConstrSpec</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(tentative)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>CS :~ ConstrSpec</H1>
Add a constraint to a constraint set
<DL>
<DT><EM>CS</EM></DT>
<DD>Constraint set or free variable
</DD>
<DT><EM>ConstrSpec</EM></DT>
<DD>A constraint specification
</DD>
</DL>
<H2>Description</H2>
<P>
	Add a constraint to a constraint set. After adding, the constraint
	will be part of the constraint set, and add to its total violatedness.
	The amount of violatedness contributed by the constraint depends on
	the constraint's implementation, but can be scaled.
	</P><P>
	Three forms of constraint specification are recognised here:
	<DL>
	<DT>Constraint</DT>
	    <DD>A constraint goal. The constraint must have a 'tentative
	    implementation', i.e. a predicate must be defined that takes one
	    additional argument and implements the violation monitoring for
	    the constraint (see constraint implementation interface).</DD>
	<DT>Weight * Constraint</DT>
	    <DD>where Weight is an integer. This means that the constraints
	    violatedness is scaled with the factor Weight before being added
	    to the total violatedness of the constraint set.</DD>
	<DT>Constraint alias Term</DT>
	    <DD>Term is the term that can be retrieved from the constraint
	    set, in place of the constraint goal itself (see cs_all/2 etc).</DD>
	<DT>Weight * Constraint alias Term</DT>
	    <DD>Conbination of both modifiers above.</DD>
	</DL>
	<P>
	If CS is a free variable, a new constraint set will be implicitly
	created (as if created with cs_create(CS, [])).
	</P>
    
<H3>Modes and Determinism</H3><UL>
<LI>:~(?, +) is det
</UL>
<H2>Examples</H2>
<PRE>
    ?- length(Xs, 5), tent_set_all(Xs, 99), CS :~ alldifferent(Xs).
    Xs = [Xi{99 -&gt; 4}, Xi{99 -&gt; 4}, Xi{99 -&gt; 4}, Xi{99 -&gt; 4}, Xi{99 -&gt; 4}]
    CS = constraint_set(TotalVio{10 -&gt; 0}, ...)
    There is 1 delayed goal.
    Yes (0.00s cpu)
    </PRE>
<H2>See Also</H2>
<A HREF="../../lib/tentative/cs_create-2.html">cs_create / 2</A>, <A HREF="../../lib/tentative/cs_clear_all-1.html">cs_clear_all / 1</A>, <A HREF="../../lib/tentative/cs_clear_satisfied-1.html">cs_clear_satisfied / 1</A>, <A HREF="../../lib/tentative/cs_violations-2.html">cs_violations / 2</A>, <A HREF="../../lib/tentative/cs_current_violations-2.html">cs_current_violations / 2</A>, <A HREF="../../lib/tentative/cs_random_worst-2.html">cs_random_worst / 2</A>, <A HREF="../../lib/tentative/cs_all_worst-2.html">cs_all_worst / 2</A>, <A HREF="../../lib/tentative/cs_all_violated-2.html">cs_all_violated / 2</A>, <A HREF="../../lib/tentative/cs_random_violated-2.html">cs_random_violated / 2</A>, <A HREF="../../lib/tentative/cs_all-2.html">cs_all / 2</A>, <A HREF="../../lib/tentative/tent_implements-2.html">tent_implements / 2</A>
</BODY></HTML>
